package com.ynny.chapter04.controller;


import com.ynny.chapter04.common.AjaxResult;
import com.ynny.chapter04.entity.User;
import com.ynny.chapter04.entity.UserDTO;
import com.ynny.chapter04.exception.UserNotFoundException;
import com.ynny.chapter04.service.UserServiceImpl;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

//@Controller
//@ResponseBody   // 所有方法 返回JSON数据格式
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserServiceImpl userService;

    //@Valid // 参数校验
    @PostMapping("/edit")
    public AjaxResult edit(@Valid @RequestBody UserDTO user){

        System.out.println(user);

//        int i = 10 / 0;
//        System.out.println(i);
        userService.edit(user);


        return AjaxResult.ok();
    }


}
